home *** CD-ROM | disk | FTP | other *** search
- " --------------------------------------------------------------------- "
- " GadTools class is the Parent class that interfaces AmigaTalk to the "
- " gadtools.library in AmigaDOS. "
- " --------------------------------------------------------------------- "
-
- Class GadTools :Glyph ! intuiMsgObj windowObj visualInfoObj !
- [
- drawBoxFrom: sPoint to: ePoint tags: tagArray ! x y w h !
- " This is a beveled box. The tags will say whether it's recessed or not "
- x <- sPoint x. " These are NOT checked against window boundaries "
- y <- sPoint y.
- w <- ePoint x.
- h <- ePoint y.
-
- <primitive 239 2 windowObj x y w h tagArray>
- |
- beginRefresh
- <primitive 239 3 2 windowObj>
- |
- endRefresh: completeFlag
- <primitive 239 3 3 windowObj completeFlag> " completeFlag = true or false"
- |
- getIMsg
- ^ intuiMsgObj <- <primitive 239 3 4 windowObj>
- |
- replyIMsg
- <primitive 239 3 5 intuiMsgObj>
- |
- refreshWindow
- <primitive 239 3 6 windowObj>
- |
- postFilterIMsg
- ^ intuiMsgObj <- <primitive 239 3 7 intuiMsgObj>
- |
- filterIMsg
- ^ intuiMsgObj <- <primitive 239 3 8 intuiMsgObj>
- |
- windowIs
- ^ windowObj " Tell subclasses what Window they are attached to "
- |
- registerTo: aWindowObject
- ^ windowObj <- aWindowObject
- |
- visualInfoObject
- ^ visualInfoObj
- |
- freeVisualInfo
- <primitive 239 3 0 visualInfoObj>.
-
- " visualInfoObj cannot be used after this unless you perform
- * getVisualInfo:tags: again
- "
-
- ^ visualInfoObj <- nil
- |
- getVisualInfo: screenObj tags: tagArray
- visualInfoObj <- <primitive 239 3 1 screenObj tagArray>.
-
- (visualInfoObj isNil)
- ifTrue: [ 'ERROR: could NOT obtain visualInfo from screen!' print.
- ^ nil
- ].
-
- ^ visualInfoObj
- |
- xxxWaitForSelection
- " Smalltalk code has to call this inside a loop if there
- * is more than one IDCMP event expected. You do NOT
- * need to use beginRefresh or endRefresh arround this
- * method. This method will return an Array Object with
- * two elements:
- * rval at: 1 -- value of Gadget (Boolean, String, Prop value or item #)
- * or Menu String.
- * rval at: 2 -- Gadget or Menu UserData field.
- *
- * use subclass methods instead.
- "
- ^ <primitive 239 3 9 windowObj>
- ]
-
- " --------------------------------------------------------------------- "
- " NewGadgets Class is the class that interfaces AmigaTalk to the "
- " new gadgets portion of gadtools.library "
- " --------------------------------------------------------------------- "
-
- Class NewGadgets :GadTools ! private gadgetList newGadgetObj windowObj !
- [
- disposeGadgetList: gadgetListObj
- <primitive 239 0 0 gadgetListObj>
- |
- allocateGadgetList
- gadgetList <- <primitive 239 0 1>.
-
- ^ self
- |
- createGadgetList
- private <- <primitive 239 0 2 gadgetList>.
-
- ^ self
- |
- disposeNewGadget: unNeededNewGadgetObj
- " You will have to keep track of every newGadgetObj returned
- * from makeNewGadget: & use this method on ALL of them
- * (unless you have memory to burn). Once you've called
- * addGadgetToList:type:tags:, a newGadgetObj is no longer
- * needed & perhaps you should use this method afterwards:
- "
- <primitive 239 0 7 unNeededNewGadgetObj>.
-
- ^ nil
- |
- makeNewGadget: structureArray
- " structureArray is an Array Object with the following
- * elements in the given order:
- * ele[1] <- ng_LeftEdge, ele[2] <- ng_TopEdge,
- * ele[3] <- ng_Width, ele[4] <- ng_Height,
- * ele[5] <- ng_GadgetText, ele[6] <- ng_TextAttr,
- * ele[7] <- ng_GadgetID, ele[8] <- ng_Flags,
- * ele[9] <- ng_VisualInfo, ele[10] <- ng_UserData
- *
- * ele[11] <- NewGadget Type Tag
- *
- * ele[10] can be any AmigaTalk Object (especially useful
- * is a Symbol describing a method to call!).
- "
- ^ newGadgetObj <- <primitive 239 0 3 structureArray>
- |
- newStructArray: initArray ! newArray !
- " Example usage:
- * gType <- intuition getGadgetType: #BUTTON_KIND
- * newGadget <- NewGadgets new
- * vi <- newGadget visualInfoObject
- * newStruct <- newStructArray: #( 10 40 100 20 'My Gadget'
- * textAttrObj 1 myFlags vi userData gType)
- * newGadgetObj <- newGadget makeNewGadget: newStruct
- "
- newArray <- Array new: 11.
-
- newArray at: 1 put: initArray at: 1.
- newArray at: 2 put: initArray at: 2.
- newArray at: 3 put: initArray at: 3.
- newArray at: 4 put: initArray at: 4.
- newArray at: 5 put: initArray at: 5.
- newArray at: 6 put: initArray at: 6.
- newArray at: 7 put: initArray at: 7.
- newArray at: 8 put: initArray at: 8.
- newArray at: 9 put: initArray at: 9.
- newArray at: 10 put: initArray at: 10.
- newArray at: 11 put: initArray at: 11.
-
- ^ newArray
- |
- addGadgetToList: gadgetObj type: gType tags: tagArray
- ^ <primitive 239 0 4 gadgetObj newGadgetObj gType tagArray>
- |
- setGadgetAttrs: tagArray
- <primitive 239 0 5 private windowObj tagArray>
- |
- getGadgetAttrs: tagArray
- ^ <primitive 239 0 6 private windowObj tagArray>
- |
- registerTo: aWindowObject
- (aWindowObject isNil)
- ifTrue: [ 'NewGadgets Object given a nil Window object!' print.
- ^ nil
- ].
-
- ^ windowObj <- (super registerTo: aWindowObject)
- |
- waitForGadgetValue ! rval !
- " Use the returned Object (or copy it) BEFORE using any method
- * that uses <primitive 239 3 9 windowObj> again!
- "
- rval <- (super xxxWaitForSelection).
-
- ^ (rval at: 1)
- |
- waitForGadgetUserData ! rval !
- " Smalltalk code has to call this inside a loop if there
- * is more than one IDCMP event expected. You do NOT
- * need to use beginRefresh or endRefresh arround this
- * method. Any AmigaTalk Object is valid as the
- * UserData stored in the NewGadget.
- *
- * Use the returned Object (or copy it) BEFORE using any method
- * that uses <primitive 239 3 9 windowObj> again!
- "
- rval <- (super xxxWaitForSelection).
-
- ^ (rval at: 2)
- ]
-
- " --------------------------------------------------------------------- "
- " NewMenus Class is the class that interfaces AmigaTalk to the "
- " new Menus portion of gadtools.library "
- ""
- " Making a menu: "
- ""
- " menu <- NewMenus new "
- " menu allocateNewMenu: 3 "
- " menu1Array <- Array new: 6 "
- " menu2Array <- Array new: 6 "
- " intuition <- Intuition new "
- ""
- " menu1Array at: 1 put: (intuition getGadToolAttr: #NM_TITLE)"
- " menu1Array at: 2 put: 'PROJECT' "
- " menu1Array at: 3 put: 0 NO nm_CommKey for a Menu Title! "
- " menu1Array at: 4 put: 0 "
- " menu1Array at: 5 put: 0 "
- " menu1Array at: 6 put: 0 "
- ""
- " menu2Array at: 1 put: (intuition getGadToolAttr: #NM_ITEM)"
- " menu2Array at: 2 put: 'Load a file..' "
- " menu2Array at: 3 put: 'L' "
- " menu2Array at: 4 put: 0 "
- " menu2Array at: 5 put: 0 "
- " menu2Array at: 6 put: 0 "
- ""
- " menu fillNewMenuItem: 1 with: menu1Array "
- " menu fillNewMenuItem: 2 with: menu2Array "
- ""
- " You MUST have one of these for a valid menu strip: "
- " menu fillNewMenuItem: 3 with: (menu endOfMenuArray: intuition) "
- ""
- " chk1 <- menu createMenuStrip: tagArray1 -- CreateMenusA() tags apply here "
- " chk2 <- initializeMenus: tagArray2 -- LayoutMenusA() tags apply here "
- " --------------------------------------------------------------------- "
-
- Class NewMenus :GadTools ! private newMenuArrayObj windowObj !
- [
- disposeMenu
- <primitive 239 1 0 private newMenuArrayObj>
- |
- allocateNewMenu: numItems ! chk !
- " newMenuArrayObj is an Array of NewMenu objects "
-
- chk <- <primitive 239 1 1 numItems>.
-
- (chk isNil)
- ifTrue: [ 'Did NOT allocateNewMenu:' print].
-
- ^ newMenuArrayObj <- chk
- |
- endOfMenuArray: intuitionObj ! endArray !
- endArray <- Array new: 6.
-
- endArray at: 1 put: (intuitionObj getGadToolAttr: #NM_END).
- endArray at: 2 put: nil. " NO nm_Label "
- endArray at: 3 put: nil. " NO nm_CommKey "
- endArray at: 4 put: 0. " NO nm_Flags "
- endArray at: 5 put: 0. " NO nm_MutualExclude"
- endArray at: 6 put: 0. " NO nm_UserData "
-
- ^ endArray
- |
- xxxMakeArray: t k: k f: f x: ex data: data ! rval !
- rval <- Array new: 6.
-
- rval at: 2 put: t.
- rval at: 3 put: k.
- rval at: 4 put: f.
- rval at: 5 put: ex.
- rval at: 6 put: data.
-
- ^ rval
- |
- initMenuArray: intObj title: title key: commKey flags: flags
- exclude: mx data: userData ! rval !
- " Make a new Menu: "
- rval <- self xxxMakeArray: title k: commKey f: flags x: mx data: userData
-
- rval at: 1 put: (intObj getGadToolAttr: #NM_TITLE).
-
- ^ rval
- |
- initMenuItemArray: intObj title: title key: commKey flags: flags
- exclude: mx data: userData ! rval !
- " Make a new MenuItem: "
- rval <- self xxxMakeArray: title k: commKey f: flags x: mx data: userData
-
- rval at: 1 put: (intObj getGadToolAttr: #NM_ITEM).
-
- ^ rval
- |
- initSubItemArray: intObj title: title key: commKey flags: flags
- exclude: mx data: userData ! rval !
- " Make a new SubItem: "
- rval <- self xxxMakeArray: title k: commKey f: flags x: mx data: userData
-
- rval at: 1 put: (intObj getGadToolAttr: #NM_SUB).
-
- ^ rval
- |
- initMenuImageArray: intObj title: title key: commKey flags: flags
- exclude: mx data: userData ! rval !
- " Make a new MenuItem: "
- rval <- self xxxMakeArray: title k: commKey f: flags x: mx data: userData
-
- rval at: 1 put: (intObj getGadToolAttr: #IM_ITEM).
-
- ^ rval
- |
- initSubImageArray: intObj title: title key: commKey flags: flags
- exclude: mx data: userData ! rval !
- " Make a new SubItem: "
- rval <- self xxxMakeArray: title k: commKey f: flags x: mx data: userData
-
- rval at: 1 put: (intObj getGadToolAttr: #IM_SUB).
-
- ^ rval
- |
- fillNewMenuItem: itemNumber with: structureArray
- " structureArray is an Array Object with the following
- * elements in the given order:
- * ele[1] <- nm_Type, ele[2] <- nm_Label,
- * ele[3] <- nm_CommKey, ele[4] <- nm_Flags,
- * ele[5] <- nm_MutualExclude, ele[6] <- nm_UserData
- *
- * ele[6] can be any AmigaTalk Object (especially useful
- * is a Symbol describing a method to call!).
- "
- (<primitive 239 1 2 itemNumber structureArray newMenuArrayObj> ~= true)
- ifTrue: [ self disposeMenu.
- 'ERROR: Could NOT fill a NewMenu entry!' print.
- ^ nil
- ]
- |
- createMenuStrip: tagArray ! chk !
- chk <- <primitive 239 1 3 newMenuArrayObj tagArray>.
-
- (chk isNil)
- ifTrue: [ 'Did NOT createMenuStrip:' print.
- ^ nil
- ].
-
- ^ private <- chk
- |
- visualInfo
- ^ (super visualInfoObject)
- |
- initializeMenus: tagArray ! chk viObj !
- " This method returns true if successful, false if the menus
- * could NOT be laid-out, nil if there is an error condition.
- "
- viObj <- self visualInfo.
- chk <- <primitive 239 1 4 private viObj tagArray>.
-
- (chk ~= true)
- ifTrue: [ 'Did NOT initialize NewMenus object!' print.
- ^ false
- ].
- ^ true
- |
- waitForMenuString ! rval !
- " Smalltalk code has to call this inside a loop if there
- * is more than one IDCMP event expected. You do NOT
- * need to use beginRefresh or endRefresh arround this
- * method.
- *
- * Use the returned Object (or copy it) BEFORE using any method
- * that uses <primitive 239 3 9 windowObj> again!
- "
- rval <- (super xxxWaitForSelection).
-
- ^ (rval at: 1)
- |
- waitForMenuUserData ! rval !
- " Smalltalk code has to call this inside a loop if there
- * is more than one IDCMP event expected. You do NOT
- * need to use beginRefresh or endRefresh arround this
- * method. Make sure that you use only AmigaTalk Objects
- * as the UserData stored in the NewMenu. This method will
- * return nil if the Menu Item selected was NULL.
- *
- * Use the returned Object (or copy it) BEFORE using any method
- * that uses <primitive 239 3 9 windowObj> again!
- "
- rval <- (super xxxWaitForSelection).
-
- ^ (rval at: 2)
- |
- registerTo: aWindowObject
- (aWindowObject isNil)
- ifTrue: [ 'NewMenus Object given a nil Window object!' print.
- ^ nil
- ].
-
- ^ windowObj <- (super registerTo: aWindowObject)
- ]
-